|  |  | @@ -17,7 +17,8 @@ from utils.group_photo_utils import get_current_photos | 
            
            
              | 17 | 17 |  from utils.redis.rgroup import get_group_info, get_group_users_info, get_group_users_kv_info, set_group_users_info | 
            
            
              | 18 | 18 |  from utils.redis.rkeys import (GROUP_LAST_PHOTO_PK, GROUP_USERS_DELETED_SET, GROUP_USERS_PASSED_SET, | 
            
            
              | 19 | 19 |                                 GROUP_USERS_QUIT_SET, GROUP_USERS_REFUSED_SET, TOUR_GUIDE_GROUP_CUR_GATHER_INFO, | 
            
            
              | 20 |  | -                               TOUR_GUIDE_GROUP_CUR_SESSION, TOUR_GUIDE_GROUP_GEO_INFO, TOUR_GUIDE_GROUP_USER_GEO_LIST) | 
            
            
              |  | 20 | +                               TOUR_GUIDE_GROUP_CUR_SESSION, TOUR_GUIDE_GROUP_GEO_INFO, TOUR_GUIDE_GROUP_GEO_SUBMIT_DT, | 
            
            
              |  | 21 | +                               TOUR_GUIDE_GROUP_USER_GEO_LIST) | 
            
            
              | 21 | 22 |  from utils.redis.rtourguide import get_tour_guide_own_group | 
            
            
              | 22 | 23 |  from utils.redis.rtouruser import set_tour_user_belong_group | 
            
            
              | 23 | 24 |   | 
            
            
            
            
              |  |  | @@ -217,6 +218,18 @@ def tgu_group_user_update_api(request): | 
            
            
              | 217 | 218 |      }) | 
            
            
              | 218 | 219 |   | 
            
            
              | 219 | 220 |   | 
            
            
              |  | 221 | +def get_geo_submit_flag(geo_at, gather_at): | 
            
            
              |  | 222 | +    """ 是否上传过位置字段(即是否失联) """ | 
            
            
              |  | 223 | +    if geo_at and gather_at: | 
            
            
              |  | 224 | +        current_dt = tc.utc_datetime() | 
            
            
              |  | 225 | +        delta_seconds = tc.total_seconds(gather_at - current_dt) | 
            
            
              |  | 226 | +        # 距离集合时间超过30分钟是5分钟,15分钟到30分钟是3分钟,15分钟以内是1分钟 | 
            
            
              |  | 227 | +        for delta, gdt in [(1800, 300), (900, 180), (0, 60)]: | 
            
            
              |  | 228 | +            if delta_seconds > delta: | 
            
            
              |  | 229 | +                return tc.total_seconds(current_dt - geo_at) <= gdt | 
            
            
              |  | 230 | +    return False | 
            
            
              |  | 231 | + | 
            
            
              |  | 232 | + | 
            
            
              | 220 | 233 |  @logit | 
            
            
              | 221 | 234 |  def tgu_group_user_locations_api(request): | 
            
            
              | 222 | 235 |      """ 旅行团所有成员位置信息 """ | 
            
            
            
            
              |  |  | @@ -230,6 +243,9 @@ def tgu_group_user_locations_api(request): | 
            
            
              | 230 | 243 |      # 获取集合经纬度 | 
            
            
              | 231 | 244 |      gather_info = json.loads(r.get(TOUR_GUIDE_GROUP_CUR_GATHER_INFO % group_id) or '{}') | 
            
            
              | 232 | 245 |   | 
            
            
              |  | 246 | +    # GEO submit dts | 
            
            
              |  | 247 | +    geo_dts = r.hgetall(TOUR_GUIDE_GROUP_GEO_SUBMIT_DT % group_id) | 
            
            
              |  | 248 | + | 
            
            
              | 233 | 249 |      # [['x', 0.33, (2.68220901489e-06, 1.26736058093e-06)], []] | 
            
            
              | 234 | 250 |      locations = r.georadius(TOUR_GUIDE_GROUP_GEO_INFO % group_id, gather_info.get('gather_lon', 0), gather_info.get('gather_lat', 0), '+inf', unit='m', withdist=True, withcoord=True, sort='ASC') | 
            
            
              | 235 | 251 |      # [{'lon': 2.68220901489e-06, 'lat': 26736058093e-06, 'dist': 0.33, etc...}, {}] | 
            
            
            
            
              |  |  | @@ -238,7 +254,8 @@ def tgu_group_user_locations_api(request): | 
            
            
              | 238 | 254 |      locations = [dict(group_users_kv_info[loc[0]], **{ | 
            
            
              | 239 | 255 |          'lon': loc[2][0], | 
            
            
              | 240 | 256 |          'lat': loc[2][1], | 
            
            
              | 241 |  | -        'dist': loc[1] | 
            
            
              |  | 257 | +        'dist': loc[1], | 
            
            
              |  | 258 | +        'geo_submited': get_geo_submit_flag(tc.utc_string_to_utc_datetime(geo_dts.get(loc[0], '')), gather_info.get('gather_at', '')), | 
            
            
              | 242 | 259 |      }) for loc in locations] | 
            
            
              | 243 | 260 |   | 
            
            
              | 244 | 261 |      return response(200, 'Get Tour Guide Group All User Location Success', u'获取旅行团成员地理位置信息成功', { |